package com.ming.collection;

import java.util.*;

public class CollectionDemo {
    public static void main(String[] args) {
        List<Book> books = Arrays.asList(new Book("1",1), new Book("2",2));

        Iterator<Book> iterator = books.iterator();
        while (iterator.hasNext()){
            Book next = iterator.next();
            System.out.println(next==books.get(0));
        }
        for (Book book : books) {
            System.out.println(book==books.get(0));
        }
        Collections.sort(books);
        System.out.println(books);
        ArrayList<Object> list = new ArrayList<>();
        list.remove(0);
        new Vector<>().add(2);
        new LinkedList<>().set(1,2);
        HashSet<Object> objects = new HashSet<>();
    }
}

class Book implements Comparable<Book>{
    private String name;
    private int age;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Book(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Book(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Book{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }


    @Override
    public int compareTo(Book o) {
        return -o.getAge();
    }
}
